#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS     10

void *PrintHello(void *threadid);//this bit is a void pointer
int array1[50]; //surely I have to populate this array somehow? Threadid is it?
//for pthreads2, this void pointer needs to become an int
//how do I recast in c?
int t; //maybe a global variable for the loop would help
//this would be fine if the data were int but I can't say for sure it is
void *PrintHello(void *threadid)
{
	int threadNum = (int) threadid; //Big thanks for showing me recast syntax. I'll be ok now
	//printout statements go here
	printf("I am doing %d now\n", threadNum);//%ld for long int and %d for regular int

/* these are experimental	
	for(int i=0;i<array.length;i++)
	{
		//fill the array with threadid
		array.add[%d]
		printf("The array contains %d");
	}
*/
}

int main (int argc, char *argv[])
{
   pthread_t threads[NUM_THREADS];

   for(int t = 0; t < NUM_THREADS; t++){//t is 5 as defined by NUM_THREADS up the top
	int threadid = (int) threadid;
	printf("I am doing %d now\n", threadid);//funny that myself and Martin got the same number
	//returns 13454025 for some reason
      int rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
	//can't see where this is used
	//NULL, PrintHello, (void *)t);
   }

   // Last thing that main() should do
   pthread_exit(NULL);
}//don't forget -lpthread when compiling
//when in doubt, comment it out 8)
//cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++ [enabled by default]
//pthreads3.C: In function ‘int main(int, char**)’:
//pthreads3.C:25:29: error: expected ‘;’ before ‘)’ token
//it was the same for 4 years of doing Java in fact. The code would never compile.
//thanks again for the assist with the recast
//compile switch is gcc <program name> -lpthread
//for part b, surely it depends on the number of cores? Dividing by core count might work.
//This way, each core shares the total job load evenly
